import { readdir } from 'fs/promises';
import { resolve } from 'path'


export async function readFileList() {


    const files = await readdir(resolve(__dirname, '../../../static/courses/'));

    let fileList = await Promise.all(files.map(async (fileName) => {
        return { [fileName]: (await readdir(resolve(__dirname, `../../../static/courses/${fileName}`))).filter((name) => name.includes('.html')) };
    }));

    fileList = Array.from(new Set(fileList));


    return fileList;

}